package com.zzf.concurrent.example.design.pattern.thread.local.context;

import com.zzf.concurrent.example.util.TimeUtil;

/**
 * @author GaoFeng2017
 * @date 2019/9/8 14:48
 */
public class PostageDao {


    public PostageDao() {
    }

    /**
     * 查询订单邮费
     * @author ZengZhengFang
     * @date 2019/9/8 14:56
     * @param
     * @return int
     */
    public int queryPostage(OrderContext context) {

        // 获取用户信息
        Object userInfo = context.getUserInfo();
        // 获取表单参数
        Object formData = context.getFormData();

        // 调用数据库查询
        TimeUtil.sleep(1000);

        return userInfo.hashCode() * formData.hashCode();
    }

    public int queryPostage() {

        OrderContext context = OrderContextUtil.getContext();

        // 获取用户信息
        Object userInfo = context.getUserInfo();
        // 获取表单参数
        Object formData = context.getFormData();

        // 调用数据库查询
        TimeUtil.sleep(1000);

        return userInfo.hashCode() * formData.hashCode();
    }

}
